import Vue from 'vue';
//引入路由
import VueRouter from 'vue-router';
Vue.use(VueRouter);

//创建组件，引入组件
import Home from '../components/Home.vue';
import News from '../components/News.vue';
import NewsCnt from '../components/NewsCnt.vue';
import Product from '../components/Product.vue';
import Personal from '../components/Personal.vue';

import User from '../components/User.vue';
import UserAdd from '../components/user/UserAdd.vue';
import UserList from '../components/user/UserList.vue';
 

//路由配置
const routes = [
  { path: '/home', component: Home },
  { path: '/news', component: News },
  { path: '/personal', component: Personal },
  { 
  	path: '/user', component:User,
  	children: [
        {
          path: 'useradd',
          component: UserAdd
        },
        {
          path: 'userlist',
          component: UserList
        }
    ]
  },
  { path: '/newscnt/:aid', component: NewsCnt,name:'newscnt' },//动态路由
  { path: '/product', component: Product },
  { path: '*', redirect: '/home' }//默认跳转路由
];
//实例化VueRouter
const router = new VueRouter({
  routes // （缩写）相当于 routes: routes
});

export default router;